package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.ServiceOrder;
import wiki.douzi.helpyougrow.mapper.ServiceOrderMapper;
import wiki.douzi.helpyougrow.service.ServiceOrderService;
import org.springframework.stereotype.Service;

import java.util.List;
import javax.annotation.Resource;

/**
 * (ServiceOrder)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:20
 */
@Service("serviceOrderService")
public class ServiceOrderServiceImpl implements ServiceOrderService {
    @Resource
    private ServiceOrderMapper serviceOrderMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<ServiceOrder> queryAll() {
        return this.serviceOrderMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ServiceOrder queryById(Integer id) {
        return this.serviceOrderMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param serviceOrder 实例对象
     * @return 实例对象
     */
    @Override
    public ServiceOrder insert(ServiceOrder serviceOrder) {
        this.serviceOrderMapper.insert(serviceOrder);
        return serviceOrder;
    }

    /**
     * 修改数据
     *
     * @param serviceOrder 实例对象
     * @return 实例对象
     */
    @Override
    public ServiceOrder update(ServiceOrder serviceOrder) {
        this.serviceOrderMapper.update(serviceOrder);
        return this.queryById(serviceOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.serviceOrderMapper.deleteById(id) > 0;
    }
}

